<?php

m2import('base/templateEngine/Cache.php');

class base_templateEngine_CacheHelper {

    public static function deleteImageCache ($imgId) {
        $mcache = new base_templateEngine_Cache(base_templateEngine_Cache::$IMAGEMETA_DIR, true);
        $icache = new base_templateEngine_Cache(base_templateEngine_Cache::$IMAGE_DIR, true);
        $mkey = base_templateEngine_CacheKeyBuilder::buildImageMetaKey($imgId);
        if ($mcache->test($mkey)) {
            $meta = $mcache->load($mkey);
            if (is_array($meta)) {
                foreach ($meta as $m) {
                    $wh = preg_split('/_/', $m);
                    $icache->delete(base_templateEngine_CacheKeyBuilder::buildImageKey($imgId, $wh[0], $wh[1]));
                }
            }
        }
    }

}